﻿@using LightSO.CMS.Model.EasyUI
@{
    Tabs Tabs = null;
    if (ViewBag.Tabs == null)
    {
        Tabs = Tabs.Create(ViewBag);
    }
    else
    {
        Tabs = ViewBag.Tabs;
    }
    string version = "20150605";
    var tabIndex = Request["tabindex"] == null ? 0 : Convert.ToInt32(Request["tabindex"]);
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Html.Partial("~/Views/Shared/Shared.cshtml")
    @if (!string.IsNullOrWhiteSpace(Tabs.ScriptSrc))
    {
        <script type="text/javascript" src="@Tabs.ScriptSrc?version=@version"></script>
    }
    <script type="text/javascript">
        @RenderSection("EnumDefine", false)
        $(function () {
            $('#@(Tabs.Id)').tabs({
                onSelect: function (title, index) {
                    @{
                        var script = RenderSection("OnSelect", false);
                        if (script != null)
                        {
                            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"</?script[^<>]*>");
                            @Html.Raw(regex.Replace(script.ToHtmlString(), string.Empty));
                            @:return this.onSelect(title, index);
                        }
                    }
                }
            });
            @{
                var onload = RenderSection("OnLoad", false);
                if (onload != null)
                {
                    System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"</?script[^<>]*>");
                    @Html.Raw(regex.Replace(onload.ToHtmlString(), string.Empty));
                }
            }

            if (parseInt(@tabIndex) > 0)
                $('#@(Tabs.Id)').tabs("select", parseInt(@tabIndex));
        });
    </script>
</head>
<body>

    <div class="easyui-panel" id="tabs_panel_@(Tabs.Id)" title="@Tabs.Title" data-options="fit:true,border:false" style="overflow:hidden;">
        @*工具条*@
        @{var toolbar = RenderSection("ToolbarMenu", false);}
        @if (toolbar != null)
        { 
            <div class="datagrid-toolbar" style="height:26px;" id="tabs_toolbar_@(Tabs.Id)">
                @Html.Raw(toolbar.ToHtmlString())
            </div>
        }

        <div id="@(Tabs.Id)" class="easyui-tabs" data-options="fit:true,border:false" style="overflow:hidden;">
            @RenderBody()
            @foreach (var item in Tabs.Buttons)
            {
                Tab tab = item.Value;
                <div title="@tab.Title" data-options="fit:true,border:false,iconCls:'@tab.Icon'" style="overflow:hidden;padding-top:2px">
                    @if (!string.IsNullOrWhiteSpace(tab.Url))
                    {
                        <iframe id="ifrm_@(Tabs.Id)_@(tab.Id)" scrolling="no" frameborder="0" src="@(tab.Url)" style="width:100%;height:100%;"></iframe>
                    }
                    else
                    {
                        @RenderSection(tab.Id + "Panel", false)
                    }
                </div>
            }
        </div>

    </div>
</body>
</html>
